execute as @e[tag=hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run scoreboard players set @s advm_power 1
execute as @s[tag=!hasPower] run scoreboard players set @s advm_power 0

tag @s add finding

# 1 
# 2 

execute as @s[nbt={ItemRotation:1b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~1 ~ ~ if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:1b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~-1 ~ ~ if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:1b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~ ~ ~-1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:1b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~ ~ ~1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit


execute as @s[nbt={ItemRotation:2b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~1 ~ ~1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:2b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~-1 ~ ~1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:2b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~1 ~ ~-1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit
execute as @s[nbt={ItemRotation:2b}] if score @s advm_power matches 1.. at @s positioned ~ ~ ~ align y run execute at @s positioned ~-1 ~ ~-1 if entity @e[tag=!hasPower,type=item_frame,distance=..1,limit=1,sort=nearest,nbt={Tags:["wire"]}] run function advm:machines/wire_states_edit

tag @s remove finding